<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet" />
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
	.bootbox-close-button {
		width: 19px;
		height: 19px;
		border: none;
		cursor: pointer;
		-webkit-appearance: none;
		float: right;
		top: 4px;
		left: -5px;
		position: relative;
		background: #E9F5FF url("assets/img/nav-img/icon_close.png") no-repeat 0 0;
	}

	.margin-bottom-15 {
		margin-bottom: 15px !important;
	}

	.bs-example label{
		margin:0px!important;
	}
	.tssTranstiClassesListDialog  .modal-dialog{
		width: 50%;
	}
</style>
<div class="row" style="margin-left: 0px!important;">
	<input type="hidden"  name="memberPackageId" class="memberPackageId" value="${memberPackageId}"/>
	<p class="text-right" style="padding: 20px 0;margin: 0;">会员王华华，可选课课时数：22课时</p>
	<#list listMap as data>
		<div class="panel-group" id="accordion">
			<div class="panel panel-info">
				<div class="panel-heading">
					<h4 class="panel-title" data-toggle="collapse" data-parent="#accordion"
						href="#collapse${data_index+1}" style="cursor: pointer;">
						<a>${data.courseName}</a>
						<a class="float-right">收起</a>
					</h4>
				</div>
				<div id="collapse${data_index+1}" class="panel-collapse collapse in">
					<div class="panel-body">
						<p class="text-center">课程日期：${data.startDate}-${data.endDate} ${data.startTime}-${data.endTime}，${data.weekDay} 课程节数：${data.expendClassHour}节 单节消耗课时数：${data.pitchNumber}</p>
						<form class="bs-example bs-example-form" role="form">
							<div class="row" style="margin-left: 0px!important;"  id="checkbox${data_index+1}" class="checkboxBox">
								<div class="btn-toolbar" role="toolbar" style="margin: 10px;">
									<#list data["lessonsList"] as cl>
										<div class="col-xs-4 lableDiv" style="border: 1px solid #ccc;padding-top: 5px;padding-bottom: 5px">
											<lable class="col-xs-2">
												<input  type="checkbox" name="clId" class="chk" value="${cl.id}"style="position: static;opacity: 1;margin: 0;width: 18px;height: 18px;">
											</lable>
											<label class="col-xs-2">
												${cl_index+1}
											</label>
											<label class="col-xs-5">
												${cl.classTime}
											</label>
											<label class="col-xs-3">
												<@dictionary groupCode="weekDay" dictionaryCode="${data.weekDay}" ;weekDay>${weekDay.value }</@dictionary>
											</label>
										</div>
									</#list>
								</div>
							</div>
							<div class="row" style="margin-left: 0px!important;" >
								<div class="btn-toolbar" role="toolbar" style="margin: 10px;">
									<div class="btn-group">
										<label>
											<input type="checkbox" class="checkboxs${data_index+1}" style="position: static;opacity: 1;margin: 0;width: 18px;height: 18px;">
										</label>
										<label>全选</label>
										<label>可选课时数不足，请购买或激活其他课时包</label>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</#list>

	<div class="col-sm-12 text-align-center">
		<button style="width: 80px;margin-right: 20px" type="button" class="btn btn-blue" data-dismiss="modal" serializeNum="${serializeNum}"
				targetdataId="${data.id}" onclick="showDialogAttendClassLessons(this)">确定
		</button>
		<input style="width: 80px;" type="button" class="btn btn-blue" data-dismiss="modal" value="取消" />
	</div>
</div>



<script src="assets/js/validation/bootstrapValidator_init.js"></script>
<script>

    $(function () {
        $('#collapseOne').collapse('toggle')
    });

    for (var i=1;i<=$(".panel-group").length;i++) {

        $('#collapse'+i).on('show.bs.collapse', function () {
            $(this).siblings(".panel-heading").children(".panel-title").children(".float-right").html("收起")
        })
        $('#collapse'+i).on('hide.bs.collapse', function () {
            $(this).siblings(".panel-heading").children(".panel-title").children(".float-right").html("展开")
        })

        checkboxChange(i);

    }

    function checkboxChange(i) {
        $(".checkboxs"+i).change(function () {
            if ($(this).is(':checked')) {
                $("#checkbox"+i+" input").prop("checked", true);
            } else {
                $("#checkbox"+i+" input").prop("checked", false);
            }
        })
    }



    $(".selectpicker_${serializeNum}").select2();

    function showDialogAttendClassLessons() {
        var memberPackageId = $(".memberPackageId").val();
        var allCheckVlaues = new Array();
        $("[name='clId']:checked").map(function (index, chk) {
            var value = chk.value;
            /*  var values = new Array();
              $("[parentCheckId='clId_" + value + "']:checked").map(function (index, chek1) {
                  values.push(chek1.value);
              });
              allCheckVlaues.push(value + ":" + values.join(","));*/
            allCheckVlaues.push(value);
        });
        var allCheckVlauesStr = allCheckVlaues.join(",");
        console.log(allCheckVlauesStr);
        ajaxRequest("tssMemberAttendClassRecordController/saveOrUpdate.do", {
            targetDataId: allCheckVlauesStr,
            memberPackageId: memberPackageId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "报班记录",
                className: 'myDialog'
            });

        }, function () {
            ajaxError("加载页面失败!")
        }, "post", "html")
    }


    /**
     * 获取指定复选框选中的值字符串
     * @param inputName 复选框name属性值,默认是id
     * @param separator 分隔符,默认为逗号
     * @returns {String} 复选框选中的值字符串
     */
    function getCheckedInputValuesClId(inputName, separator) {
        if (!inputName) {
            inputName = "clId";
        }
        if (!separator) {
            separator = ",";
        }
        var inputs = $("[name='" + inputName + "']:checked");
        var count = inputs.size();
        var values = "";
        for (var i = 0; i < count; i++) {
            values += inputs.eq(i).val();
            if (i != count - 1) {
                values += ",";
            }
        }
        return values;
    }
</script>